package com.example.day7.model;

import com.example.day7.base.BaseModel;
import com.example.day7.bean.FuliBean;
import com.example.day7.not.ApiService;
import com.example.day7.not.HttpUlist;
import com.example.day7.not.RxUlist;

import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

public class FuliModel extends BaseModel {
    public void addFuliModel(FuliCallBack callBack){
        ApiService apiServer = new HttpUlist().getApiServer(ApiService.Fuli, ApiService.class);
        Observable<FuliBean> getdata = apiServer.getdata();
        getdata.compose(RxUlist.RxObservableTransformer())
                .subscribe(new Observer<FuliBean>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(FuliBean fuliBean) {
                        callBack.onSuccess(fuliBean);
                    }

                    @Override
                    public void onError(Throwable e) {
                        callBack.onFali(e.getMessage());
                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }
}
